package com.yupi.springbootinit.manager;

import com.yupi.springbootinit.common.ErrorCode;
import com.yupi.springbootinit.exception.BusinessException;
import com.yupi.springbootinit.exception.ThrowUtils;
import com.yupi.yucongming.dev.client.YuCongMingClient;
import com.yupi.yucongming.dev.common.BaseResponse;
import com.yupi.yucongming.dev.model.DevChatRequest;
import com.yupi.yucongming.dev.model.DevChatResponse;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
@Component
public class AIManager {
    @Resource
    private  YuCongMingClient yuCongMingClient;
    public  String doChart(Long ModelId,String Message){
        DevChatRequest devChatRequest = new DevChatRequest();
        devChatRequest.setModelId(ModelId);
        devChatRequest.setMessage(Message);
        BaseResponse<DevChatResponse> response = yuCongMingClient.doChat(devChatRequest);
        ThrowUtils.throwIf(response.getMessage().equals("鱼毛不足"),
                new BusinessException(ErrorCode.FORBIDDEN_ERROR,"羊毛不足啦充值呀！"));
//        ThrowUtils.throwIf(response.getData()==null,
//                new BusinessException(ErrorCode.FORBIDDEN_ERROR,response.getMessage()));
        if (response.getData()==null){
            return response.getMessage();
        }
        return response.getData().getContent();
    }
}
